<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>libdill</title>
  <link rel="stylesheet" type="text/css" href="main.css">
</head>
<body>

<h1>libdill: Structured Concurrency for C</h1>

<ul id='toplist'>
<li><a href="index.html">Home</a></li>
<li><a href="download.html">Download</a></li>
<li><a href="documentation.html">Documentation</a></li>
<li><a href="tutorial.html">Tutorials</a></li>
<li><a href="faq.html">FAQ</a></li>
</ul>
<h1 id="name">NAME</h1>
<p>hown - transfer ownership of a handle</p>
<h1 id="synopsis">SYNOPSIS</h1>
<div class="sourceCode"><pre class="sourceCode c"><code class="sourceCode c"><span class="pp">#include </span><span class="im">&lt;libdill.h&gt;</span>

<span class="dt">int</span> hown(
    <span class="dt">int</span> h);</code></pre></div>
<h1 id="description">DESCRIPTION</h1>
<p>Handles are integers. You own a handle if you know its numeric value. To transfer ownership this function changes the number associated with the object. The old number becomes invalid and using it will result in undefined behavior. The new number can be used in exactly the same way as the old one would.</p>
<p>If the function fails, the old handle is closed.</p>
<p><strong>h</strong>: Handle to transfer.</p>
<h1 id="return-value">RETURN VALUE</h1>
<p>In case of success the function returns new handle. In case of error it returns -1 and sets <strong>errno</strong> to one of the values below.</p>
<h1 id="errors">ERRORS</h1>
<ul>
<li><strong>EBADF</strong>: Invalid handle.</li>
<li><strong>EMFILE</strong>: The maximum number of file descriptors in the process are already open.</li>
<li><strong>ENFILE</strong>: The maximum number of file descriptors in the system are already open.</li>
<li><strong>ENOMEM</strong>: Not enough memory.</li>
</ul>
<h1 id="example">EXAMPLE</h1>
<div class="sourceCode"><pre class="sourceCode c"><code class="sourceCode c"><span class="dt">int</span> h1 = tcp_connect(&amp;addr, deadline);
<span class="dt">int</span> h2 = hown(h1);
<span class="co">/* h1 is invalid here */</span>
hclose(h2);</code></pre></div>
<h1 id="see-also">SEE ALSO</h1>
<p><strong>hclose</strong>(3) <strong>hclose</strong>(3) <strong>hmake</strong>(3) <strong>hquery</strong>(3)</p>
</body>
